package com.aspose.cells;

class zco {
   static String a(byte[] var0, int var1, boolean var2, int var3) {
      String var4 = null;
      if (!var2) {
         var4 = Encoding.getUnicode().a(var0, var1, var3 * 2);
      } else {
         byte[] var5 = new byte[2 * var3];

         for(int var6 = 0; var6 < var3; ++var6) {
            var5[2 * var6] = var0[var1 + var6];
         }

         var4 = Encoding.getUnicode().a(var5, 0, var5.length);
      }

      return var4;
   }

   static String a(byte[] var0, int var1) {
      int var2 = com.aspose.cells.b.a.zc.e(var0, var1) & '\uffff';
      String var3 = null;
      int var10000;
      if (var0[var1 + 2] == 1) {
         var3 = Encoding.getUnicode().a(var0, var1 + 3, var2 * 2);
         var10000 = var1 + 3 + var2 * 2;
      } else {
         byte[] var4 = new byte[2 * var2];

         for(int var5 = 0; var5 < var2; ++var5) {
            var4[2 * var5] = var0[var1 + 3 + var5];
         }

         var3 = Encoding.getUnicode().a(var4, 0, var4.length);
         var10000 = var1 + 3 + var2;
      }

      return var3;
   }

   static String a(byte[] var0, int[] var1) {
      int var2 = com.aspose.cells.b.a.zc.e(var0, var1[0]) & '\uffff';
      if (var2 == 0) {
         var1[0] += 3;
         return null;
      } else {
         String var3 = null;
         if (var0[var1[0] + 2] == 1) {
            var3 = Encoding.getUnicode().a(var0, var1[0] + 3, var2 * 2);
            var1[0] += 3 + var2 * 2;
         } else {
            byte[] var4 = new byte[2 * var2];

            for(int var5 = 0; var5 < var2; ++var5) {
               var4[2 * var5] = var0[var1[0] + 3 + var5];
            }

            var3 = Encoding.getUnicode().a(var4, 0, var4.length);
            var1[0] += 3 + var2;
         }

         return var3;
      }
   }

   static byte[] a(String var0) {
      if (var0 != null && !"".equals(var0)) {
         boolean var3 = true;
         byte[] var2 = Encoding.getUnicode().a(var0);

         int var4;
         for(var4 = 0; var4 < var2.length / 2; ++var4) {
            if (var2[2 * var4 + 1] != 0) {
               var3 = false;
               break;
            }
         }

         byte[] var1;
         if (var3) {
            var1 = new byte[var2.length / 2];

            for(var4 = 0; var4 < var2.length / 2; ++var4) {
               var1[var4] = var2[2 * var4];
            }
         } else {
            var1 = var2;
         }

         return var1;
      } else {
         return null;
      }
   }

   static String a(byte[] var0, int var1, int var2) {
      byte[] var3 = new byte[2 * var2];

      for(int var4 = 0; var4 < var2; ++var4) {
         var3[2 * var4] = var0[var1 + var4];
      }

      return Encoding.getUnicode().a(var3);
   }

   static int a(byte[] var0, int var1, byte[] var2, String var3) {
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var3.length()), 0, var0, var1, 2);
      var1 += 2;
      boolean var4 = var2.length == var3.length();
      var0[var1++] = (byte)(var4 ? 0 : 1);
      System.arraycopy(var2, 0, var0, var1, var2.length);
      return 3 + var2.length;
   }

   static int a(byte[] var0, int var1, String var2) {
      byte[] var3 = zakq.a(var2);
      boolean var4 = var3.length == var2.length();
      var0[var1++] = (byte)(var4 ? 0 : 1);
      System.arraycopy(var3, 0, var0, var1, var3.length);
      return 1 + var3.length;
   }

   static int a(byte[] var0, int[] var1, String var2) {
      boolean var3 = false;
      int var5;
      if (var2 == null) {
         int var10004 = var1[0];
         int var10001 = var1[0];
         var1[0] = var10004 + 1;
         var0[var10001] = -1;
         var10004 = var1[0];
         var10001 = var1[0];
         var1[0] = var10004 + 1;
         var0[var10001] = -1;
         var5 = 2;
      } else {
         System.arraycopy(com.aspose.cells.b.a.zc.a((short)var2.length()), 0, var0, var1[0], 2);
         var1[0] += 2;
         int var4 = a(var0, var1[0], var2);
         var1[0] += var4;
         var5 = 2 + var4;
      }

      return var5;
   }

   static int a(byte[] var0, int var1, String var2, int var3, byte var4) {
      int var6 = var2.length() + 1;
      if (var3 == 1) {
         var0[var1] = (byte)var6;
      } else {
         if (var3 != 2) {
            throw new IllegalArgumentException();
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a((short)var6), 0, var0, var1, 2);
      }

      int var5 = var1 + var3;
      byte[] var7 = zakq.a(var2);
      boolean var8 = var7.length == var2.length();
      var0[var5++] = (byte)(var8 ? 0 : 1);
      var0[var5++] = var4;
      System.arraycopy(var7, 0, var0, var5, var7.length);
      var5 += var7.length;
      if (var8) {
         var0[var5++] = 0;
      } else if (var3 == 2) {
         System.arraycopy(com.aspose.cells.b.a.zc.a((short)0), 0, var0, var5, 2);
         var5 += 2;
      }

      return var5 - var1;
   }
}
